49a5f20c6755e2f939ed142d087d74e6cc082de4,src/main/java/org/thymeleaf/engine/ProcessorTemplateHandler.java,ProcessorTemplateHandler,handleText,#IText#,422
Before Change
/*
* PROCESS THE QUEUE, launching all the queued events
*/
if (model != null) {
if (this.throttleEngine) {
stackPendingProcessing(new SimpleProcessableModel(model, modelHandler));
handlePending();
} else {
model.process(modelHandler);
}
After Change
/*
* If processing is stopped, we should queue this for later handling
*/
if (this.throttleEngine && this.templateFlowController.stopProcessing) {
queueEvent(itext);
return;
}
/*
* CHECK WHETHER WE ARE GATHERING AN ELEMENT's MODEL
*/
if (!this.eventModelController.shouldProcessText(itext)) {
return;
}
/*
* FAIL FAST in case this structure has no associated processors.
*/
if (this.textProcessors.length == 0) {
this.next.handleText(itext);
return;
}
/*
* CAST EVENT TO ENGINE-SPECIFIC IMPLEMENTATION
*/
Text text = Text.asEngineText(itext);
/*
* DECLARE VARIABLES THAT MIGHT BE NEEDED FOR TAKING ACTIONS INSTRUCTED BY THE PROCESSORS
*/
boolean discardEvent = false;
Model model = null;
ITemplateHandler modelHandler = this;
final TextStructureHandler structureHandler = this.textStructureHandler;
/*
* EXECUTE PROCESSORS
*/
for (int i = 0; !discardEvent && i < this.textProcessors.length; i++) {
structureHandler.reset();
this.textProcessors[i].process(this.context, text, structureHandler);
if (structureHandler.setText) {
text = new Text(structureHandler.setTextValue);
} else if (structureHandler.replaceWithModel) {
model = resetModel(model, true);
model.addModel(structureHandler.replaceWithModelValue);
modelHandler = structureHandler.replaceWithModelProcessable? this : this.next;
discardEvent = true;
} else if (structureHandler.removeText) {
model = null;
discardEvent = true;
}
}
/*
* PROCESS THE REST OF THE HANDLER CHAIN
*/
if (!discardEvent) {
this.next.handleText(text);
}
/*
* PROCESS THE QUEUED MODEL IF NEEDED (or handle it as pending if we are throttling the engine)
*/
if (model == null || model.size() == 0) {
return;
}
if (!this.throttleEngine) {
model.process(modelHandler);
}
stackPendingProcessing(new SimpleProcessableModel(model, modelHandler, this.templateFlowController));
// Note it is EXTREMELY IMPORTANT that this is the last line in this handling method
handlePending();
}